package leetcode;

import org.junit.Test;

public class demo494 {
    int count=0;
    public int findTargetSumWays(int[] nums, int S) {
        calculate(nums,0,0, S);
        return count;
    }
    public void calculate(int[] nums, int i, int sum, int S) {
        if(i==nums.length){
            if(sum==S)count++;
        }else{
            calculate(nums,i+1,sum+nums[i],S);
            calculate(nums,i+1,sum-nums[i],S);
        }
    }
    @Test
    public void test(){
        int[] a={1, 1, 1, 1, 1};
        findTargetSumWays(a,3);
    }
}
